
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>字符串解码（括号嵌套） - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>字符串解码（括号嵌套） - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">文档中描述的“字符串解码”问题的编码规则是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">编码规则为 `k[encoded_string]`，表示其中方括号内部的 `encoded_string` 正好重复 k 次。</div>
          </div>
          <div class="card-source">来源: 题目描述</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">算法</div>
          <div class="card-question">解决括号嵌套的字符串解码问题，文档推荐的核心算法或数据结构是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">算法</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档推荐的核心算法是使用栈（Stack）。</div>
          </div>
          <div class="card-source">来源: 核心考点/算法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在使用栈解决字符串解码问题时，当遍历到左括号 `[` 时，应该执行什么操作？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当遇到左括号 `[` 时，应将当前正在构建的字符串和已解析的重复次数（数字）一同入栈，然后重置这两个变量以处理括号内的新内容。</div>
          </div>
          <div class="card-source">来源: 解题思路 / 示例代码</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在使用栈解码字符串时，当遍历到右括号 `]` 时，具体的操作流程是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">遇到右括号 `]` 时，从栈中弹出一个元素（包含之前的字符串和重复次数）。然后，将当前括号内解码好的字符串按弹出的次数进行重复，并将其拼接到弹出的“之前的字符串”后面，形成新的当前字符串。</div>
          </div>
          <div class="card-source">来源: 解题思路 / 示例代码</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">文档中提到的栈解决方案，其时间和空间复杂度分别是多少？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该解决方案的时间复杂度为 O(n)，空间复杂度也为 O(n)。</div>
          </div>
          <div class="card-source">来源: 解题思路</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">示例代码中的 `Stack<Pair<String, Integer>>` 是如何协同工作的？它存储了什么信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">它通过将字符串和其对应的重复次数封装在一个 `Pair` 对象中来协同工作。每当遇到一个 `[` 时，它会把 `[` 之前累计的字符串（`prevString`）和数字（`repeatTimes`）作为一个 `Pair` 压入栈中，从而保存了解码的上下文状态。</div>
          </div>
          <div class="card-source">来源: 示例代码</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
